package com.klod.news.data

// 定义网络请求结果的密封类
sealed interface NetworkResult<out T> {
    data class Success<T>(val data: T) : NetworkResult<T>
    data class Error(val exception: NetworkError) : NetworkResult<Nothing>
    data class Loading(val loadingMsg:String = "正在加载") : NetworkResult<Nothing>
}

// 定义错误类型
sealed class NetworkError(val message: String) {
    class HttpError(val code: Int, message: String) : NetworkError(message)
    class NetworkUnavailable(message: String = "当前网络不可用") : NetworkError(message)
    class ConnectError(message: String = "服务器连接失败哦") : NetworkError(message)
    class UnknownError(message: String = "未知异常") : NetworkError(message)
    class SerializationError(message: String = "Serialization error") : NetworkError(message)
}